{% extends "base.html" %}

{% block title %}SYSU flea market - {{ user.username }}{% endblock %}

{% block page_content %}
<div class="page-header">
    <img class="img-rounded profile-thumbnail-usr" src="{{ user.gravatar(size=256) }}">
    <div class="profile-header">
        <h1>{{ user.username }}</h1>
        {% if user.signature or user.location %}
        <p>
            {% if user.signature %}{{ user.signature }}<br>{% endif %}
            {% if user.location %}
                来自： <a href="http://maps.google.com/?q={{ user.location }}">{{ user.location }}</a><br>
            {% endif %}
        </p>
        {% endif %}

        {% if user.about_me %}<p>{{ user.about_me }}</p>{% endif %}
        <p>加入时间 {{ moment(user.member_since).format('L') }}. 最近一次登录 {{ moment(user.last_seen).fromNow() }}.</p>
        <p>总共发表 {{ user.posts.count() }} 篇文章.</p>
        <p>
            {% if current_user.is_authenticated %}
            {% if user != current_user %}
                {% if not current_user.is_following(user) %}
                <a href="{{ url_for('.follow', username=user.username) }}" class="btn btn-primary">关注</a>
                {% else %}
                <a href="{{ url_for('.unfollow', username=user.username) }}" class="btn btn-default">取消关注</a>
                {% endif %}
            {% endif %}
            {% endif %}
            <a href="{{ url_for('.followers', username=user.username) }}">关注者:
                 <span class="badge">{{ user.followers.count() - 1 }}</span>
            </a>
            <a href="{{ url_for('.followed_by', username=user.username) }}">关注的人: 
                <span class="badge">{{ user.followed.count() - 1 }}</span>
            </a>
            {% if current_user.is_authenticated %}
            {% if user != current_user and user.is_following(current_user) %}
            | <span class="label label-default">关注了你</span>
            {% endif %}
            {% endif %}
        </p>
        <p>
            {% if user == current_user %}
            <a class="btn btn-default" href="{{ url_for('main.edit_profile') }}">编辑个人资料</a>
            {% endif %}

        </p>
    </div>
</div>
<h3>Posts by {{ user.username }}</h3>
{% include '_posts.html' %}
{% endblock %}